package com.xbn.netty.nettyByteBuf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

/**
 * @author XBN
 * @date 2020/10/21 13:19
 * @email 78742541@qq.com
 */
public class NettyByteBuf {
    public static void main(String[] args) {
        //先创建一个ByteBuf
        //Unpooled.buffer(10)创建一个对象，该对象包含一个数组arr，是一个byte[10]
        //在netty的ByteBuf中，不需要调用flip进行反转
        ByteBuf buffer = Unpooled.buffer(10);
        for (int i = 0; i < buffer.capacity(); i++) {
            buffer.writeByte(i);
        }
        //输出
        for (int i = 0; i < buffer.capacity(); i++) {
            System.out.println(buffer.readByte());
            System.out.println(buffer.getByte(i));
        }
    }
}
